package phonecompany.phone;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * This eum class is used to confine the area code of the phone numbers
 * 
 * @since Oct 24, 2011
 * @author <a href="mailto:zexpp5@gmail.com">Zexu.Lin</a>
 * @version $Id: AreaCode.java 28 2011-10-30 21:25:58Z zexpp5@gmail.com $
 * 
 */
public enum AreaCode implements Serializable {
	area1(7927), area2(7928), area3(7929);
	private final int ac;

	AreaCode(int ac) {
		this.ac = ac;
	}

	int areaCode() {
		return ac;
	}

	/**
	 * to get the Areacode by its number.
	 * 
	 * @param n
	 * @return
	 * @description
	 * 
	 * @author <a href="mailto:zexpp5@gmail.com">Zexu.Lin</a>
	 * @update Oct 30, 2011 7:25:35 PM
	 */
	public static AreaCode area(int n) {
		switch (n) {
		case 7927:
			return AreaCode.area1;
		case 7928:
			return AreaCode.area2;
		case 7929:
			return AreaCode.area3;
		default:
			throw new IllegalArgumentException(String.valueOf(n));
		}
	}

}
